package session.stateful;

import entity.RedemptionListEntity;
import java.util.Date;
import java.util.List;
import javax.ejb.Stateful;
import javax.ejb.LocalBean;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

/**
 *
 * @author Dell
 */
@Stateful
@LocalBean
public class RedemptionSessionBean {

    @PersistenceContext
    EntityManager entityManager;

    public void addRedemptionList(RedemptionListEntity list) {
        list.setDateCreated(new Date());
        entityManager.persist(list);
    }

    public void editRedemptionList(RedemptionListEntity list) {
        entityManager.merge(list);
    }

    public List<RedemptionListEntity> getAllRedemptionList() {
        Query query = entityManager.createQuery("SELECT r FROM RedemptionListEntity r");
        return query.getResultList();
    }
}
